~ chicken-core (chicken-5) /manual/Module (chicken process-context posix)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken process-context posix)
5
6This module provides access to POSIX-specific procedures which deal
7with the current process context.
8
9* New in CHICKEN 5.4.0: Errors caused by underlying C calls that
10 change errno will produce a condition object with an {{errno}}
11 property, which can be accessed with
12 {{(get-condition-property <the-condition-object> 'exn 'errno)}}.
13
14=== Process filesystem context
15
16==== change-directory*
17
18<procedure>(change-directory* FD)</procedure>
19<procedure>(set! (current-directory) FD)</procedure>
20
21Changes the current working directory to the one represented by the
22file-descriptor {{FD}}, which should be an exact integer.
23
24'''NOTE''': Windows does not allow {{{open}}} on directories, so while
25technically it is supported, in practice you cannot use this procedure
26on native Windows builds (on cygwin it works because cygwin emulates
27this).
28
29==== set-root-directory!
30
31<procedure>(set-root-directory! STRING)</procedure>
32
33Sets the root directory for the current process to the path given in
34{{STRING}} (using the {{chroot}} function). If the current process
35has no root permissions, the operation will fail.
36
37'''NOTE''': On native Windows builds (all except cygwin), this
38procedure is unimplemented and will raise an error.
39
40
41=== Retrieving user & group information
42
43==== current-user-id
44
45<procedure>(current-user-id)</procedure>
46<setter>(set! (current-user-id) UID)</setter>
47
48Get or set the real user-id of the current process. The procedure corresponds to the getuid and setuid C functions.
49
50'''NOTE''': On native Windows builds (all except cygwin), this
51procedure is unimplemented and will raise an error.
52
53==== current-user-name
54
55<procedure>(current-user-name)</procedure>
56
57Get the login name corresponding to the real user-id of the current
58process from the system password database.
59
60On Windows, there's no user-id and no distinction between real and
61effective user, but this procedure ''will'' return the username
62associated with the current process, so it is safe to use.
63
64
65==== current-effective-user-id
66
67<procedure>(current-effective-user-id)</procedure>
68<setter>(set! (current-effective-user-id) UID)</setter>
69
70Get or set the effective user-id of the current process.
71
72'''NOTE''': On native Windows builds (all except cygwin), this
73procedure is unimplemented and will raise an error.
74
75==== current-effective-user-name
76
77<procedure>(current-effective-user-name)</procedure>
78
79Get the login name corresponding to the effective user-id of the
80current process from the system password database.
81
82'''NOTE''': On native Windows builds (all except cygwin), this
83procedure is unimplemented and will raise an error.
84
85==== current-group-id
86
87<procedure>(current-group-id)</procedure>
88<setter>(set! (current-group-id) GID)</setter>
89
90Get or set the real group-id of the current process.
91
92'''NOTE''': On native Windows builds (all except cygwin), this
93procedure is unimplemented and will raise an error.
94
95==== current-effective-group-id
96
97<procedure>(current-effective-group-id)</procedure>
98<setter>(set! (current-effective-group-id) GID)</setter>
99
100Get or set the effective group-id of the current process.
101ID can be found, then {{#f}} is returned.
102
103'''NOTE''': On native Windows builds (all except cygwin), this
104procedure is unimplemented and will raise an error.
105
106
107=== Process identity
108
109==== current-process-id
110
111<procedure>(current-process-id)</procedure>
112
113Returns the process ID of the current process.
114
115==== parent-process-id
116
117<procedure>(parent-process-id)</procedure>
118
119Returns the process ID of the parent of the current process.
120
121'''NOTE''': On native Windows builds (all except cygwin), this
122procedure is unimplemented and will raise an error.
123
124==== process-group-id
125
126<procedure>(process-group-id PID)</procedure>
127<setter>(set! (process-group-id PID) PGID)</setter>
128
129Get or set the process group ID of the process specified by {{PID}}.
130
131'''NOTE''': On native Windows builds (all except cygwin), this
132procedure is unimplemented and will raise an error.
133
134==== create-session
135
136<procedure>(create-session)</procedure>
137
138Creates a new session with the current process as group leader. Returns current process id on success. Equivalent to setsid(2).
139
140==== user-information
141
142<procedure>(user-information USER [AS-VECTOR])</procedure>
143
144If {{USER}} specifes a valid username (as a string) or user ID, then
145the user database is consulted and a list of 7 values are returned:
146the user-name, the encrypted password, the user ID, the group ID, a
147user-specific string, the home directory and the default shell. When
148{{AS-VECTOR}} is {{#t}} a vector of 7 elements is returned instead of
149a list. If no user with this name or id then {{#f}} is returned.
150
151Note: on Android systems, the user-specific string is always {{""}},
152since {{pw_gecos}} is not available in the C {{passwd}} struct on that
153platform.
154
155'''NOTE''': On native Windows builds (all except cygwin), this
156procedure is unimplemented and will raise an error.
157
158---
159Previous: [[Module (chicken process-context)]]
160
161Next: [[Module (chicken random)]]